package com.zmn.oms.dubbo.impl.zmn.normal.orderstock;

import com.zmn.common.dto2.ResponseDTO;
import com.zmn.common.utils.reflect.BeanMapper;
import com.zmn.consts.GlobalConsts;
import com.zmn.oms.dubbo.dto.zmn.orderstock.OrderStockDIO;
import com.zmn.oms.dubbo.dto.zmn.orderstock.OrderStockDRO;
import com.zmn.oms.dubbo.interfaces.zmn.normal.orderstock.OrderStockRemoteService;
import com.zmn.oms.dubbo.utils.DubboConsts;
import com.zmn.oms.model.dto.orderstock.OrderStockDTO;
import com.zmn.oms.model.vo.orderstock.OrderStockVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;

/**
 * 类描述：订单库存
 *
 * @author heciqi
 * @date 2020/05/08 16:14
 */
@Slf4j
@Service(loadbalance = "roundrobin", timeout = 20000, version = DubboConsts.INTERFACE_VERSION, validation = "false")
public class OrderStockRemoteServiceImpl implements OrderStockRemoteService {
	/**
	 * 获取下单库存
	 *
	 * @param orderStockDIO
	 * @return
	 */
	@Override
	public ResponseDTO<OrderStockDRO> getOrderStock(OrderStockDIO orderStockDIO) {
		log.info("订单库存-入参==>[{}]", orderStockDIO);
		try {
			OrderStockVO orderStock = OrderStockVO.builder()
					.canServ(GlobalConsts.YES)
					.build();
			OrderStockDRO stockDRO = BeanMapper.map(orderStock, OrderStockDRO.class);
			log.info("订单库存-出参==>[{}]", stockDRO);
			return ResponseDTO.success(stockDRO);
		} catch (Exception e) {
			log.error(e.getMessage(), e);
			return ResponseDTO.success(OrderStockDRO.builder().canServ(GlobalConsts.YES).build());
		}
	}
}
